import java.io.IOException;

public final class Interface {
	public static Archive archive;
	private static Cache imageCache;
	private static final Cache modelCache = new Cache(30);
	public static Interface interfaceCache[];
	public boolean aBoolean227;
	public boolean aBoolean235;
	public boolean aBoolean259;
	public byte opacity;
	public String actions[];
	public int fontID;
	public int sprite1ID;
	public int sprite2ID;
	public int anInt208;
	public int anInt216;
	public int anInt219;
	public int anInt233;
	public int anInt239;
	public int anInt246;
	private int anInt255;
	private int anInt256;
	public int anInt257;
	public int anInt258;
	public int anInt263;
	public int anInt265;
	public int anIntArray212[];
	public int anIntArray245[];
	public String disabledMessage;
	public int atActionType;
	public boolean centerText;
	public int children[];
	public int childX[];
	public int childY[];
	public int contentType;// anInt214
	public boolean drawsTransparent;
	public int height;
	public int id;
	public int inv[];
	public int invSpritePadX;
	public int invSpritePadY;
	public int invStackSizes[];
	public boolean isInventoryInterface;
	public boolean hoverable;
	public int mediaID;
	public String message;
	public int modelRotation1;
	public int modelRotation2;
	public int modelZoom;
	public int hover;
	public int parentID;
	public Font font;
	public int scrollMax;
	public int scrollPosition;
	public String selectedActionName;
	public String spellName;
	public int spellUsableOn;
	public Sprite sprite1;
	public Sprite sprite2;
	public Sprite sprites[];
	public int spritesX[];
	public int spritesY[];
	public int textColor;
	public boolean textShadow;
	public String tooltip;
	public int type;
	public boolean usableItemInterface;
	public int valueIndexArray[][];
	public int width;

	public static void pack() {
		try {
			Packet buffer = new Packet(new byte[999999]);
			buffer.putShort(Interface.interfaceCache.length);
			for (Interface screen : Interface.interfaceCache) {
				if (screen == null) {
					continue;
				}
				int parent = screen.parentID;
				if (screen.parentID != -1) {
					buffer.putShort(65535);
					buffer.putShort(parent);
					buffer.putShort(screen.id);
				} else {
					buffer.putShort(screen.id);
				}
				buffer.putByte(screen.type);
				buffer.putByte(screen.atActionType);
				buffer.putShort(screen.contentType);
				buffer.putShort(screen.width);
				buffer.putShort(screen.height);
				buffer.putByte(screen.opacity);
				if (screen.hover != -1) {
					//byteV.writeShortSpaceSaver(screen.hover);
					buffer.putShort(screen.hover);
				} else {
					buffer.putByte(0);
				}
				int array245Count = 0;
				if (screen.anIntArray245 != null) {
					array245Count = screen.anIntArray245.length;
				}
				buffer.putByte(array245Count);
				if (array245Count > 0) {
					for (int i = 0; i < array245Count; i++) {
						buffer.putByte(screen.anIntArray245[i]);
						buffer.putShort(screen.anIntArray212[i]);
					}
				}
				int valueLength = 0;
				if (screen.valueIndexArray != null) {
					valueLength = screen.valueIndexArray.length;
				}
				buffer.putByte(valueLength);
				if (valueLength > 0) {
					for (int l1 = 0; l1 < valueLength; l1++) {
						int i3 = screen.valueIndexArray[l1].length;
						buffer.putShort(i3);
						for (int l4 = 0; l4 < i3; l4++) {
							buffer.putShort(screen.valueIndexArray[l1][l4]);
							if (screen.id == 15260) {
								System.out.println("Value [" + l1 + "][" + l4 + "]");
							}
						}
					}
				}
				if (screen.type == 0) {
					buffer.putShort(screen.scrollMax);
					buffer.putByte(screen.hoverable ? 1 : 0);
					buffer.putShort(screen.children.length);
					for (int i = 0; i < screen.children.length; i++) {
						buffer.putShort(screen.children[i]);
						buffer.putShort(screen.childX[i]);
						buffer.putShort(screen.childY[i]);
					}
				} else if (screen.type == 1) {
					buffer.putShort(0);
					buffer.putByte(0);
				} else if (screen.type == 2) {
					buffer.putByte(screen.aBoolean259 ? 1 : 0);
					buffer.putByte(screen.isInventoryInterface ? 1 : 0);
					buffer.putByte(screen.usableItemInterface ? 1 : 0);
					buffer.putByte(screen.aBoolean235 ? 1 : 0);
					buffer.putByte(screen.invSpritePadX);
					buffer.putByte(screen.invSpritePadY);
					for (int i = 0; i < 20; i++) {
						buffer.putByte(screen.sprites[i] == null ? 0 : 1);
						if (screen.sprites[i] != null) {
							buffer.putShort(screen.spritesX[i]);
							buffer.putShort(screen.spritesY[i]);
							//byteV.writeString(screen.sprites[i].myDirectory);
						}
					}
					for (int i = 0; i < 5; i++) {
						if (screen.actions[i] != null) {
							buffer.putString(screen.actions[i]);
						} else {
							buffer.putString("");
						}
					}
				} else if (screen.type == 3) {
					buffer.putByte(screen.aBoolean227 ? 1 : 0);
				}
				if ((screen.type == 4) || (screen.type == 1)) {
					buffer.putByte(screen.centerText ? 1 : 0);
					buffer.putByte(screen.fontID);
					buffer.putByte(screen.textShadow ? 1 : 0);
				}
				if (screen.type == 4) {
					buffer.putString(screen.message);
					buffer.putString(screen.disabledMessage);
				}
				if ((screen.type == 1) || (screen.type == 3) || (screen.type == 4)) {
					buffer.putInt(screen.textColor);
				}
				if ((screen.type == 3) || (screen.type == 4)) {
					buffer.putInt(screen.anInt219);
					buffer.putInt(screen.anInt216);
					buffer.putInt(screen.anInt239);
				}
				if (screen.type == 5) {
					//if (screen.sprite1 != null) {
					//if (screen.sprite1.myDirectory != null) {
					//buffer.writeLine(screen.sprite1Name + "," + screen.sprite1ID);
					//} else {
					//buffer.writeLine("");
					//}
					//} else {
					buffer.putString("");
					//}
					//if (screen.sprite2 != null) {
					//if (screen.sprite2.myDirectory != null) {
					//buffer.writeString(screen.sprite2Name + "," + screen.sprite2ID);
					//} else {
					//buffer.writeString("");
					//}
					//} else {
					//buffer.writeLine("");
					//}
					//if (screen.hoverSprite1 != null) {
					// if(screen.hoverSprite1.myDirectory != null) {
					//buffer.writeLine(screen.hoverSprite1Name + "," + screen.hoverSprite1ID);
					//System.out.println(screen.hoverSprite1Name + "," + screen.hoverSprite1ID);
					// } else {
					// buffer.writeLine("");
					// }
					//} else {
					//buffer.writeLine("");
					//}
					//if (screen.hoverSprite2 != null) {
					// if(screen.hoverSprite2.myDirectory != null) {
					//buffer.writeLine(screen.hoverSprite2Name + "," + screen.hoverSprite2ID);
					//System.out.println(screen.hoverSprite2Name + "," + screen.hoverSprite2ID);
					// } else {
					// buffer.writeLine("");
					// }
					//} else {
					//buffer.writeLine("");
					//}
				} else if (screen.type == 6) {
					if ((screen.anInt233 != -1) && (screen.mediaID > 0)) {
						buffer.putShort(screen.mediaID);
					} else {
						buffer.putByte(0);
					}
					if (screen.anInt256 > 0) {
						buffer.putShort(screen.anInt256);
					} else {
						buffer.putByte(0);
					}
					if (screen.anInt257 > 0) {
						buffer.putShort(screen.anInt257);
					} else {
						buffer.putByte(0);
					}
					if (screen.anInt258 > 0) {
						buffer.putShort(screen.anInt258);
					} else {
						buffer.putByte(0);
					}
					buffer.putShort(screen.modelZoom);
					buffer.putShort(screen.modelRotation1);
					buffer.putShort(screen.modelRotation2);
				} else if (screen.type == 7) {
					buffer.putByte(screen.centerText ? 1 : 0);
					buffer.putByte(screen.fontID);
					buffer.putByte(screen.textShadow ? 1 : 0);
					buffer.putInt(screen.textColor);
					buffer.putShort(screen.invSpritePadX);
					buffer.putShort(screen.invSpritePadY);
					buffer.putByte(screen.isInventoryInterface ? 1 : 0);
					for (int i = 0; i < 5; i++) {
						if (screen.actions[i] != null) {
							buffer.putString(screen.actions[i]);
						} else {
							buffer.putString("");
						}
					}
				}
				if ((screen.atActionType == 2) || (screen.type == 2)) {
					buffer.putString(screen.selectedActionName);
					buffer.putString(screen.spellName);
					buffer.putShort(screen.spellUsableOn);
				}
				if (screen.type == 8) {
					buffer.putString(screen.message);
				}
				if ((screen.atActionType == 1) || (screen.atActionType == 4)
				|| (screen.atActionType == 5) || (screen.atActionType == 6)) {
					buffer.putString(screen.tooltip);
				}
			}
			java.io.DataOutputStream dos = new java.io.DataOutputStream(
			new java.io.FileOutputStream(Signlink.findcachedir() + "data2.dat"));
			dos.write(buffer.buffer, 0, buffer.offset);
			dos.close();
			System.out.println("Interfaces saved.");
		} catch (IOException e) {
			System.out.println("Failed to save interfaces.");
			e.printStackTrace();
		}
	}

	public static void addButton(int id, int sid, String spriteName, String tooltip, int w, int h) {
		Interface tab = Interface.interfaceCache[id] = new Interface();
		tab.id = id;
		tab.parentID = id;
		tab.type = 5;
		tab.atActionType = 1;
		tab.contentType = 0;
		tab.opacity = (byte) 0;
		tab.hover = 52;
		tab.sprite1 = Interface.imageLoader(sid, spriteName);
		tab.sprite2 = Interface.imageLoader(sid, spriteName);
		tab.width = w;
		tab.height = h;
		tab.tooltip = tooltip;
	}

	public static void addHoverButton(int i, String imageName, int j, int width, int height,
	String text, int contentType, int hoverOver, int aT) {// hoverable button
		Interface tab = Interface.addTabInterface(i);
		tab.id = i;
		tab.parentID = i;
		tab.type = 5;
		tab.atActionType = aT;
		tab.contentType = contentType;
		tab.opacity = 0;
		tab.hover = hoverOver;
		tab.sprite1 = Interface.imageLoader(j, imageName);
		tab.sprite2 = Interface.imageLoader(j, imageName);
		tab.width = width;
		tab.height = height;
		tab.tooltip = text;
	}

	public static void addHoveredButton(int i, String imageName, int j, int w, int h, int IMAGEID) {// hoverable button
		Interface tab = Interface.addTabInterface(i);
		tab.parentID = i;
		tab.id = i;
		tab.type = 0;
		tab.atActionType = 0;
		tab.width = w;
		tab.height = h;
		tab.hoverable = true;
		tab.opacity = 0;
		tab.hover = -1;
		tab.scrollMax = 0;
		Interface.addHoverImage(IMAGEID, j, j, imageName);
		tab.totalChildren(1);
		tab.child(0, IMAGEID, 0, 0);
	}

	public static void addHoverImage(int i, int j, int k, String name) {
		Interface tab = Interface.addTabInterface(i);
		tab.id = i;
		tab.parentID = i;
		tab.type = 5;
		tab.atActionType = 0;
		tab.contentType = 0;
		tab.width = 512;
		tab.height = 334;
		tab.opacity = 0;
		tab.hover = 52;
		tab.sprite1 = Interface.imageLoader(j, name);
		tab.sprite2 = Interface.imageLoader(k, name);
	}

	public static Interface addScreenInterface(int id) {
		Interface tab = Interface.interfaceCache[id] = new Interface();
		tab.id = id;
		tab.parentID = id;
		tab.type = 0;
		tab.atActionType = 0;
		tab.contentType = 0;
		tab.width = 512;
		tab.height = 334;
		tab.opacity = (byte) 0;
		tab.hover = 0;
		return tab;
	}

	public static void addSprite(int id, int spriteId, String spriteName) {
		Interface tab = Interface.interfaceCache[id] = new Interface();
		tab.id = id;
		tab.parentID = id;
		tab.type = 5;
		tab.atActionType = 0;
		tab.contentType = 0;
		tab.opacity = (byte) 0;
		tab.hover = 52;
		tab.sprite1 = Interface.imageLoader(spriteId, spriteName);
		tab.sprite2 = Interface.imageLoader(spriteId, spriteName);
		tab.width = 512;
		tab.height = 334;
	}

	public static Interface addTabInterface(int id) {
		Interface tab = Interface.interfaceCache[id] = new Interface();
		tab.id = id;// 250
		tab.parentID = id;// 236
		tab.type = 0;// 262
		tab.atActionType = 0;// 217
		tab.contentType = 0;
		tab.width = 512;// 220
		tab.height = 700;// 267
		tab.opacity = (byte) 0;
		tab.hover = -1;// Int 230
		return tab;
	}

	public static void addText(int id, String text, Font fonts[], int idx, int color,
	boolean center, boolean shadow) {
		Interface tab = Interface.addTabInterface(id);
		tab.parentID = id;
		tab.id = id;
		tab.type = 4;
		tab.atActionType = 0;
		tab.width = 0;
		tab.height = 11;
		tab.contentType = 0;
		tab.opacity = 0;
		tab.hover = -1;
		tab.centerText = center;
		tab.textShadow = shadow;
		tab.font = fonts[idx];
		tab.message = text;
		tab.disabledMessage = "";
		tab.textColor = color;
		tab.anInt219 = 0;
		tab.anInt216 = 0;
		tab.anInt239 = 0;
	}

	public static void addTransparentSprite(int id, int spriteId, String spriteName) {
		Interface tab = Interface.interfaceCache[id] = new Interface();
		tab.id = id;
		tab.parentID = id;
		tab.type = 5;
		tab.atActionType = 0;
		tab.contentType = 0;
		tab.opacity = (byte) 0;
		tab.hover = 52;
		tab.sprite1 = Interface.imageLoader(spriteId, spriteName);
		tab.sprite2 = Interface.imageLoader(spriteId, spriteName);
		tab.width = 512;
		tab.height = 334;
		tab.drawsTransparent = true;
	}

	private static Sprite imageLoader(int index, String name) {
		long l = (TextUtil.method585(name) << 8) + index;
		Sprite sprite = (Sprite) Interface.imageCache.get(l);
		if (sprite != null) {
			return sprite;
		}
		try {
			sprite = new Sprite(name + " ", index);
			Interface.imageCache.put(sprite, l);
		} catch (Exception exception) {
			return null;
		}
		return sprite;
	}

	private static Sprite method207(int i, Archive archive, String s) {
		long l = (TextUtil.method585(s) << 8) + i;
		Sprite sprite = (Sprite) Interface.imageCache.get(l);
		if (sprite != null) {
			return sprite;
		}
		try {
			sprite = new Sprite(archive, s, i);
			Interface.imageCache.put(sprite, l);
		} catch (Exception _ex) {
			return null;
		}
		return sprite;
	}

	public static void method208(boolean flag, Model model) {
		int i = 0;// was parameter
		int j = 5;// was parameter
		if (flag) {
			return;
		}
		Interface.modelCache.clear();
		if ((model != null) && (j != 4)) {
			Interface.modelCache.put(model, (j << 16) + i);
		}
	}

	public static void unpack(Archive data, Font fonts[], Archive content) {
		Interface.imageCache = new Cache(50000);
		Packet buffer = new Packet(data.getFile("data"));
		int i = -1;
		int j = buffer.getUnsignedShort();
		Interface.interfaceCache = new Interface[j + 10000];
		while (buffer.offset < buffer.buffer.length) {
			int k = buffer.getUnsignedShort();
			if (k == 65535) {
				i = buffer.getUnsignedShort();
				k = buffer.getUnsignedShort();
			}
			Interface iComponent = Interface.interfaceCache[k] = new Interface();
			iComponent.id = k;
			iComponent.parentID = i;
			iComponent.type = buffer.getUnsignedByte();
			iComponent.atActionType = buffer.getUnsignedByte();
			iComponent.contentType = buffer.getUnsignedShort();
			iComponent.width = buffer.getUnsignedShort();
			iComponent.height = buffer.getUnsignedShort();
			iComponent.opacity = (byte) buffer.getUnsignedByte();
			iComponent.hover = buffer.getUnsignedByte();
			if (iComponent.hover != 0) {
				iComponent.hover = (iComponent.hover - 1 << 8) + buffer.getUnsignedByte();
			} else {
				iComponent.hover = -1;
			}
			int i1 = buffer.getUnsignedByte();
			if (i1 > 0) {
				iComponent.anIntArray245 = new int[i1];
				iComponent.anIntArray212 = new int[i1];
				for (int j1 = 0; j1 < i1; j1++) {
					iComponent.anIntArray245[j1] = buffer.getUnsignedByte();
					iComponent.anIntArray212[j1] = buffer.getUnsignedShort();
				}
			}
			int k1 = buffer.getUnsignedByte();
			if (k1 > 0) {
				iComponent.valueIndexArray = new int[k1][];
				for (int l1 = 0; l1 < k1; l1++) {
					int i3 = buffer.getUnsignedShort();
					iComponent.valueIndexArray[l1] = new int[i3];
					for (int l4 = 0; l4 < i3; l4++) {
						iComponent.valueIndexArray[l1][l4] = buffer.getUnsignedShort();
					}
				}
			}
			if (iComponent.type == 0) {
				iComponent.drawsTransparent = false;
				iComponent.scrollMax = buffer.getUnsignedShort();
				iComponent.hoverable = buffer.getUnsignedByte() == 1;
				int i2 = buffer.getUnsignedShort();
				iComponent.children = new int[i2];
				iComponent.childX = new int[i2];
				iComponent.childY = new int[i2];
				for (int j3 = 0; j3 < i2; j3++) {
					iComponent.children[j3] = buffer.getUnsignedShort();
					iComponent.childX[j3] = buffer.getShort();
					iComponent.childY[j3] = buffer.getShort();
				}
			}
			if (iComponent.type == 1) {
				buffer.getUnsignedShort();
				buffer.getUnsignedByte();
			}
			if (iComponent.type == 2) {
				iComponent.inv = new int[iComponent.width * iComponent.height];
				iComponent.invStackSizes = new int[iComponent.width * iComponent.height];
				iComponent.aBoolean259 = buffer.getUnsignedByte() == 1;
				iComponent.isInventoryInterface = buffer.getUnsignedByte() == 1;
				iComponent.usableItemInterface = buffer.getUnsignedByte() == 1;
				iComponent.aBoolean235 = buffer.getUnsignedByte() == 1;
				iComponent.invSpritePadX = buffer.getUnsignedByte();
				iComponent.invSpritePadY = buffer.getUnsignedByte();
				iComponent.spritesX = new int[20];
				iComponent.spritesY = new int[20];
				iComponent.sprites = new Sprite[20];
				for (int j2 = 0; j2 < 20; j2++) {
					int k3 = buffer.getUnsignedByte();
					if (k3 == 1) {
						iComponent.spritesX[j2] = buffer.getShort();
						iComponent.spritesY[j2] = buffer.getShort();
						String s1 = buffer.getString();
						if ((content != null) && (s1.length() > 0)) {
							int i5 = s1.lastIndexOf(",");
							iComponent.sprites[j2] = Interface.method207(Integer.parseInt(s1
							.substring(i5 + 1)), content, s1.substring(0, i5));
						}
					}
				}
				iComponent.actions = new String[5];
				for (int l3 = 0; l3 < 5; l3++) {
					iComponent.actions[l3] = buffer.getString();
					if (iComponent.actions[l3].length() == 0) {
						iComponent.actions[l3] = null;
					}
				}
			}
			if (iComponent.type == 3) {
				iComponent.aBoolean227 = buffer.getUnsignedByte() == 1;
			}
			if ((iComponent.type == 4) || (iComponent.type == 1)) {
				iComponent.centerText = buffer.getUnsignedByte() == 1;
				iComponent.fontID = buffer.getUnsignedByte();
				if (fonts != null) {
					iComponent.font = fonts[iComponent.fontID];
				}
				iComponent.textShadow = buffer.getUnsignedByte() == 1;
			}
			if (iComponent.type == 4) {
				iComponent.message = buffer.getString();
				iComponent.disabledMessage = buffer.getString();
			}
			if ((iComponent.type == 1) || (iComponent.type == 3) || (iComponent.type == 4)) {
				iComponent.textColor = buffer.getInt();
			}
			if ((iComponent.type == 3) || (iComponent.type == 4)) {
				iComponent.anInt219 = buffer.getInt();
				iComponent.anInt216 = buffer.getInt();
				iComponent.anInt239 = buffer.getInt();
			}
			if (iComponent.type == 5) {
				iComponent.drawsTransparent = false;
				String s = buffer.getString();
				if ((content != null) && (s.length() > 0)) {
					iComponent.sprite1ID = s.lastIndexOf(",");
					iComponent.sprite1 = Interface.method207(Integer.parseInt(s
					.substring(iComponent.sprite1ID + 1)), content, s.substring(0,
					iComponent.sprite1ID));
				}
				s = buffer.getString();
				if ((content != null) && (s.length() > 0)) {
					int j4 = s.lastIndexOf(",");
					iComponent.sprite2 = Interface.method207(
					Integer.parseInt(s.substring(j4 + 1)), content, s.substring(0, j4));
				}
			}
			if (iComponent.type == 6) {
				int l = buffer.getUnsignedByte();
				if (l != 0) {
					iComponent.anInt233 = 1;
					iComponent.mediaID = (l - 1 << 8) + buffer.getUnsignedByte();
				}
				l = buffer.getUnsignedByte();
				if (l != 0) {
					iComponent.anInt255 = 1;
					iComponent.anInt256 = (l - 1 << 8) + buffer.getUnsignedByte();
				}
				l = buffer.getUnsignedByte();
				if (l != 0) {
					iComponent.anInt257 = (l - 1 << 8) + buffer.getUnsignedByte();
				} else {
					iComponent.anInt257 = -1;
				}
				l = buffer.getUnsignedByte();
				if (l != 0) {
					iComponent.anInt258 = (l - 1 << 8) + buffer.getUnsignedByte();
				} else {
					iComponent.anInt258 = -1;
				}
				iComponent.modelZoom = buffer.getUnsignedShort();
				iComponent.modelRotation1 = buffer.getUnsignedShort();
				iComponent.modelRotation2 = buffer.getUnsignedShort();
			}
			if (iComponent.type == 7) {
				iComponent.inv = new int[iComponent.width * iComponent.height];
				iComponent.invStackSizes = new int[iComponent.width * iComponent.height];
				iComponent.centerText = buffer.getUnsignedByte() == 1;
				int l2 = buffer.getUnsignedByte();
				if (fonts != null) {
					iComponent.font = fonts[l2];
				}
				iComponent.textShadow = buffer.getUnsignedByte() == 1;
				iComponent.textColor = buffer.getInt();
				iComponent.invSpritePadX = buffer.getShort();
				iComponent.invSpritePadY = buffer.getShort();
				iComponent.isInventoryInterface = buffer.getUnsignedByte() == 1;
				iComponent.actions = new String[5];
				for (int k4 = 0; k4 < 5; k4++) {
					iComponent.actions[k4] = buffer.getString();
					if (iComponent.actions[k4].length() == 0) {
						iComponent.actions[k4] = null;
					}
				}
			}
			if ((iComponent.atActionType == 2) || (iComponent.type == 2)) {
				iComponent.selectedActionName = buffer.getString();
				iComponent.spellName = buffer.getString();
				iComponent.spellUsableOn = buffer.getUnsignedShort();
			}
			if (iComponent.type == 8) {
				iComponent.message = buffer.getString();
			}
			if ((iComponent.atActionType == 1) || (iComponent.atActionType == 4)
			|| (iComponent.atActionType == 5) || (iComponent.atActionType == 6)) {
				iComponent.tooltip = buffer.getString();
				if (iComponent.tooltip.length() == 0) {
					if (iComponent.atActionType == 1) {
						iComponent.tooltip = "Ok";
					}
					if (iComponent.atActionType == 4) {
						iComponent.tooltip = "Select";
					}
					if (iComponent.atActionType == 5) {
						iComponent.tooltip = "Select";
					}
					if (iComponent.atActionType == 6) {
						iComponent.tooltip = "Continue";
					}
				}
			}
		}
		Interface.archive = data;
		Interface.imageCache = null;
	}

	public void child(int id, int interID, int x, int y) {
		children[id] = interID;
		childX[id] = x;
		childY[id] = y;
	}

	private Model method206(int i, int j) {
		Model model = (Model) Interface.modelCache.get((i << 16) + j);
		if (model != null) {
			return model;
		}
		if (i == 1) {
			model = Model.method462(j);
		}
		if (i == 2) {
			model = EntityDefinition.forID(j).method160();
		}
		if (i == 3) {
			model = Client.myPlayer.method453();
		}
		if (i == 4) {
			model = ItemDefinition.forID(j).method202(50);
		}
		if (i == 5) {
			model = null;
		}
		if (model != null) {
			Interface.modelCache.put(model, (i << 16) + j);
		}
		return model;
	}

	public Model method209(int j, int k, boolean flag) {
		Model model;
		if (flag) {
			model = method206(anInt255, anInt256);
		} else {
			model = method206(anInt233, mediaID);
		}
		if (model == null) {
			return null;
		}
		if ((k == -1) && (j == -1) && (model.colors == null)) {
			return model;
		}
		Model model_1 = new Model(true, FrameReader.method532(k)
		& FrameReader.method532(j), false, model);
		if ((k != -1) || (j != -1)) {
			model_1.method469();
		}
		if (k != -1) {
			model_1.method470(k);
		}
		if (j != -1) {
			model_1.method470(j);
		}
		model_1.preProcess(64, 768, -50, -10, -50, true);
		return model_1;
	}

	public void swapInventoryItems(int i, int j) {
		int k = inv[i];
		inv[i] = inv[j];
		inv[j] = k;
		k = invStackSizes[i];
		invStackSizes[i] = invStackSizes[j];
		invStackSizes[j] = k;
	}

	public void totalChildren(int t) {
		children = new int[t];
		childX = new int[t];
		childY = new int[t];
	}

	public Interface() {
	}
}
